﻿<!DOCTYPE html>
<!--作业许可证管理=>作业许可证申请=>特殊作业选择 -->
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

    <style>
        .el-dialog__body {
            height: 100% !important;
        }

        .el-dialog.is-fullscreen {
            overflow: hidden !important;
        }
 
        body {
            padding-bottom: 10px;
        }
    </style>
</head>
<body>
    
<div id="app" v-cloak>   
        <el-row>
            <el-col :span="6">
                <el-tree :data="TreeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
            </el-col>

            <el-col :span="18">
                <el-form ref="form" label-position="right" label-width="100px" :model="formInline" class="demo-form-inline" style="margin-bottom: 15px;">
                    <el-row>
                        <el-col class="head-tool">

                            <el-button type="primary" @click="onSubmit">{{col.btnSelect}}</el-button>

                            <el-button type="primary" @click="aaa">{{col.btnConfirm}}</el-button>
                            <el-button type="primary" @click="UserInput('tj')">{{col.btnAdd}}</el-button>
                        </el-col>
                    </el-row>

                    <el-row>

                        <el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.JobTicketName" :placeholder="JobLicenseManagement.JobTicketName" size="mini">
                                        <template slot="prepend">
                                            {{SpecialJobSelectionList.JobTicketName+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>

                        <el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.JobTicketCode" :placeholder="JobLicenseManagement.JobTicketCode" size="mini">
                                        <template slot="prepend">
                                            {{SpecialJobSelectionList.JobTicketCode+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                            <div class="elst-select-mini">
                                <el-form-item :label="JobLicenseManagement.ApplicationTime+mark.m" size="mini">
                                    <el-date-picker v-model="formInline.model.ApplicationTime" type="daterange" range-separator="至"
                                                    start-placeholder="开始日期" end-placeholder="结束日期" size="mini">
                                    </el-date-picker>
                                </el-form-item>
                            </div>
                        </el-col>

                    </el-row>
                </el-form>


                <el-table ref="table" :data="ListItem.tableData" :row-key="mygetRowKeys"
                          :height="ListItem.tableHeight"
                          border @selection-change="handleSelectionChange" row-style="height:10px"
                          style="width: 100%">
                    <el-table-column type="selection" :reserve-selection="true"
                                     width="55">
                    </el-table-column>
                    <el-table-column prop="ApplicationTime"
                                     :label="JobLicenseManagement.ApplicationTime">
                    </el-table-column>
                    <el-table-column prop="JobTicketName"
                                     label="作业票证名称">
                    </el-table-column>
                    <el-table-column prop="JobTicketCode"
                                     label="作业票证编码">
                    </el-table-column>
                </el-table>
                <el-row type="flex" justify="end">
                    <el-pagination ref="page" @size-change="handleSizeChange"
                                   @current-change="handleCurrentChange"
                                   :current-page="ListItem.currentPage"
                                   :page-sizes="ListItem.pagesizes"
                                   :page-size="ListItem.pagesize"
                                   :layout="ListItem.layout"
                                   :total="ListItem.total">
                    </el-pagination>
                </el-row>

            </el-col>
        </el-row>
        <el-dialog title="特殊作业管理" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="90%" height="90%" top="10vh" fullscreen="true">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
        app = new Vue({
            el: '#app',
            data: function() {
                return {
                    TreeData: [],
                    mydata: SpecialJobSelection,
                    defaultProps: {
                        children: 'children',
                        label: 'label'
                    },
                    ListItem: ListItem,
                    formInline: {
                        model: { ApplicationTime: '', JobTicketName: '', JobTicketCode: '', TreeNode: '', TreeNodeName: '' },
                        offset: 0,
                        limit: 10
                    }
                }
            }, created: function () {

                var currApp = this;

                window.onresize = function () {
                    currApp.ListItem.tableHeight = window.innerHeight -
                        currApp.$refs.table.$el.offsetTop - 60;
                    if (currApp.ListItem.tableHeight < 112) {
                        currApp.ListItem.tableHeight = 112;
                    }
                }
            },
            mounted: function () {
                //初始化数据
                var mythis = this;
                this.GetPageData(1);

                mythis.toggleSelection();
                //列表高度自适应
                tablehigh(this);
                this.TreeData = fn(this.mydata, "0");
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                handleNodeClick: function (data) {
                    console.log(data)
                    //当前节点如果为最底层的才触发新的查询?暂时先这么处理,如果每层节点都查询就把判断去掉,并在接口逻辑模糊查询
                    if (!data.children) {
                        this.formInline.model.TreeNode = data.id;
                        this.formInline.model.TreeNodeName = data.label;
                        onSubmit(this);
                    }
                },
                mygetRowKeys: function (row) {
                    return row.JobTicketName;
                },
                toggleSelection: function () {
                    var mythis = this;
                    mythis.$nextTick(function () {
                        var rows = parent.app.Form.SpecialWorkPermitTable;
                        var array = [];
                        for (var i = 0; i < rows.length; i++) {
                            var obj = {};
                            obj = rows[i];
                            array.push(obj);
                        }
                        if (array) {
                            array.forEach(function (arr) {
                                mythis.$refs.table.toggleRowSelection(arr, true);
                            });
                        } else {
                            mythis.$refs.table.clearSelection();
                        }

                    })

                },
                 //获取分页数据
                GetPageData: function (currentIndex) {

                    GetPageData(this, currentIndex, '/api/SpecialJobSelection/GetList')
                },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                handleSelectionChange: function (val) {
                    handleSelectionChange(this, val);
                },
                onSubmit: function () { onSubmit(this); },
                //跳页触发方法
                handleCurrentChange: function (val) {
                    handleCurrentChange(this, val);
                },
                aaa: function () {
                    parent.app.Form.SpecialWorkPermitTable = [];
                    for (var i = 0; i < this.ListItem.tableMultipleSelection.length; i++) {
                        parent.app.Form.SpecialWorkPermitTable.push(this.ListItem.tableMultipleSelection[i]);
                    }
                    parent.app.ListItem.dialogVisible = false;
                },
                UserInput: function (val, id) {
                    if (this.formInline.model.TreeNodeName == '') {
                        showMessage('请选择分类', 'error')
                        return;
                    }
                    switch (this.formInline.model.TreeNodeName) {
                        case "吊装（一般）":
                            DialogShow(this, val, "../JobSafetyManagement/GeneralLiftingWorkSafety/GeneralLiftingWorkSafetyInput.html", id);
                            break;
                        case "吊装（简易）":
                            DialogShow(this, val, "../JobSafetyManagement/SimpleLiftingOperation/SimpleLiftingOperationInput.html", id);
                            break;
                        case "动火":
                            DialogShow(this, val, "../JobSafetyManagement/HotWorkSafetyLicense/HotWorkSafetyLicenseInput.html", id);
                            break;
                        case "动土":
                            DialogShow(this, val, "../JobSafetyManagement/EarthmovingWorkSafetyPermit/EarthmovingWorkSafetyPermitInput.html",id);
                            break;
                        case "管线设备打开":
                            DialogShow(this, val, "../JobSafetyManagement/PipelineOpenOperationSafetyLicense/PipelineOpenOperationSafetyLicenseInput.html", id);
                            break; 
                    }
               
                },
            }
        });
    </script>
</body>
</html>